import { HttpUrlVariable } from '@/constants'
import type { SendCodeParams } from '@/types/enum'
import type {
  CodeResult,
  LoginMobileParams,
  LoginParams,
  LoginResult,
  UserData,
} from '@/types/user'
import RequestHttp from '@/utils/request'

/**
 * 登录接口
 *
 */
export const loginAPI = (data: LoginParams) =>
  RequestHttp.post<LoginResult, LoginParams>(HttpUrlVariable.LOGIN_URL, data)

/***
 * 验证码接口
 *
 */
export const sendCodeAPI = (params: SendCodeParams) =>
  RequestHttp.get<CodeResult, SendCodeParams>(HttpUrlVariable.SEND_CODE_URL, params)

/**
 * 验证码登录
 *
 */
export const loginByCodeAPI = (data: LoginMobileParams) =>
  RequestHttp.post<LoginResult, LoginMobileParams>(HttpUrlVariable.LOGIN_CODE_URL, data)

/**
 * 获取个人信息
 * **/
export const getUserInfoAPI = () => RequestHttp.get<UserData>(HttpUrlVariable.MY_USER_URL)
